var mydialog;

function cu_title_add(){
	var ba_title=$("#ba_title").val();
	var ba_remk=$("#ba_remk").val();
	var sort_id=$("#sort_id").val();
	
	if(ba_title==''){
		alert('客戶稱謂不能為空');
		return;
	}
	
	$.ajax({
		url:'cu_title',
		type:'post',
		data:{operator:'31',type:2,ba_title:ba_title,ba_remk:ba_remk,sort_id:sort_id},
		dataType:'json',
		success:cu_title_add_status,
		error:function(XMLHttpRequest, textStatus, errorThrown){alert(textStatus);}
	});
}

function cu_title_add_status(data){
	if(data.status===1){
		location.reload();
	}
}

function cu_title_alter(id){
	var data=$("#"+id).html();
	art.dialog({
		title:'客戶稱謂-修改',
		content:data,
		lock:true
	});
}

function cu_title_del(id){
	if(confirm('您確定刪除嗎?')){
		mydialog=art.dialog({title:'請稍候...',lock:true});
		$.ajax({
			url:'cu_title',
			type:'post',
			dataType:'json',
			data:{operator:'31',type:4,id:id},
			success:cu_title_del_status,
			error:function(XMLHttpRequest, textStatus, errorThrown){alert(textStatus);}
		});
	}
}

function cu_title_del_status(data){
	if(data.status===1){
		mydialog.content('刪除成功');
		location.reload();
	}
}